package com.javasea.spring.starter;

import com.javasea.spring.starter.config.DefaultImportBeanDefinitionRegistrar;
import com.javasea.spring.starter.config.SelfImportSelector;
import com.javasea.spring.starter.config2.GpDefineImportSelector;
import com.javasea.spring.starter.service.impl.CommonSaveTheWorldServiceImpl;
import com.javasea.spring.starter.service.impl.HeroSaveTheWorldImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import java.util.ArrayList;
import java.util.List;

/**
 * 自动装配类
 * @author longxiaonan
 * 注入environment和applicationContext 以便做一些后续操作
 */
// 标识需要进行bean注册，只开启@Configuration可以注入该类定义的bean。该类必须在spring.factories配置
@Configuration
// bean注册
// 方式一：
//@EnableConfigurationProperties(DeptProperties.class)
// 方式二：注入SelfImportSelector中指定的bean
@Import({SelfImportSelector.class, GpDefineImportSelector.class})
// 方式三：
//@Import({DefaultImportBeanDefinitionRegistrar.class})
public class NbAutoConfiguration1 {

    @Bean(name="books")
    public List<String> getBookList(){
        List<String> list = new ArrayList<>();
        list.add("Java面向对象编程");
        list.add("java就业编程");
        list.add("SpringBoot面向对比");
        return list;
    }

    @Bean
    public HeroSaveTheWorldImpl heroSaveTheWorld(){
        return new HeroSaveTheWorldImpl();
    }

    @Bean
    public CommonSaveTheWorldServiceImpl commonSaveTheWorldService(){
        return new CommonSaveTheWorldServiceImpl();
    }

}
